/*
 * led.h
 *
 * Created: 14/01/2013 15:23:58
 *  Author: marionse
 */ 


#ifndef MOD_RF_H_
#define MOD_RF_H_

#include "custom_type.h"

/************************************************************************/
/* CONSTANTS ET DEFINITIONS                                             */
/************************************************************************/

// taille max des data
#define MAX_MSG_SIZE 60

typedef struct  
{
	Int16U node_id;
	Int16U cluster_id;
	Int8U  cmd_id;
	Int8U  msg_size;
	Int8U  msg[MAX_MSG_SIZE];
}SRfMsg;

/************************************************************************/
/* FONTIONS                                                             */
/************************************************************************/

/**
* \brief initialized RF Module
*
* \return TRUE if success
*/
Boolean ModRfInit( void );

/**
* \brief Send a message
*/
Boolean ModRfSend( SRfMsg *ip_msg );

/**
* \brief receive a message, use has a tick function for the module
*/
Boolean ModRFReceive( SRfMsg *op_msg );

/**
* \brief create a new network
* \param[IN] ip_callback : function to call at the end of the process to indicate
*							if it's success (TRUE) or failed (FALSE)*/
Boolean ModRFCreate( void (*ip_callback)(Boolean i_success) );

/**
* \brief autorise d'autre noeud a joindre le reseau ou non
* \param[IN] i_join : TRUE if other node can join the network
*/
Boolean ModRFPermitJoining( Boolean i_join );

/**
* \brief join an existing network
* \param[IN] ip_callback : function to call at the end of the process to indicate
*							if it's success (TRUE) or failed (FALSE)*/
Boolean ModRFJoin( void (*ip_callback)(Boolean i_success) );

/**
* \brief leave current network
*/
Boolean ModRFLeave( void );


#endif /* MOD_RF_H_ */